package ar.com.notarip.bb.infosubte;

import net.rim.device.api.command.AlwaysExecutableCommand;
import net.rim.device.api.command.ReadOnlyCommandMetadata;
import net.rim.device.api.system.Clipboard;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.VerticalFieldManager;
import ar.com.notarip.bb.infosubte.util.Util;


/**
 *  @author pablo notari (notarip@gmail.com)
 * 
 * 
 */
public class Copiar extends AlwaysExecutableCommand{

	private VerticalFieldManager _manager;

	
	public Copiar(VerticalFieldManager _verticalManager) {
	
		this._manager = _verticalManager;
	
	}
	
	public void execute(ReadOnlyCommandMetadata metadata, Object context) {


		copiar();
		
	}
	
	public void copiar() {
		

		String copiaDeEstados = "";
		int fieldsCount = _manager.getFieldCount(); 
				
						
		for (int i = 0 ; i < fieldsCount ; i++){
			if (OpcionesService.validateOptions(Util.getLetraLinea(i))){
				
				HorizontalFieldManager hm = (HorizontalFieldManager) _manager.getField(i);
				copiaDeEstados += Util.getDescLinea(i) + ": " + ((RichTextField)hm.getField(1)).getText() +  '\n';
			
			}
		}
		copiaDeEstados += '\n' + "--------\n" + Util.FIRMA + "\n--------";
		Clipboard clipboard = Clipboard.getClipboard();
    	clipboard.put(copiaDeEstados);
		
	}


}
